Skip to content

fix: replace deprecated distutils.version.StrictVersion for python 3 - #14795

Open
tchbla wants to merge 5 commits into
Azure:masterfrom
tchbla:fix/remove-distutils-strict-version
Open

fix: replace deprecated distutils.version.StrictVersion for python 3#14795
tchbla wants to merge 5 commits into
Azure:masterfrom
tchbla:fix/remove-distutils-strict-version

Conversation

@tchbla

@tchbla tchbla commented Jul 30, 2026

Copy link
Copy Markdown

Change(s):

Updated Sentinel_AMA_troubleshoot.py

  • Replaced from distutils.version import StrictVersion with a local _parse_version() helper that converts dotted-version strings to comparable integer tuples. The helper pads shorter tuples to three components (e.g. 1.2 -> (1, 2, 0)) to preserve StrictVersion's equality semantics.
  • Added two blank lines before _parse_version per PEP 8 E302.

Updated Solutions/ESET Inspect/Data Connectors/InspectGetDetections/__init__.py

  • Replaced from distutils.util import strtobool with an inline _strtobool() helper that matches the original behavior, including raising ValueError on unrecognized values.

Reason for Change(s):

distutils was fully removed in Python 3.13, causing an ImportError on any machine running Python 3.13+.
No third-party dependencies are introduced, the behaviour is identical.
The tuple comparison follows the same ordering as StrictVersion for the dotted-integer version strings used in this script, and _strtobool is a faithful reimplementation of distutils.util.strtobool.

Version Updated:

Updated inline Script Version to 2.52 Sentinel_AMA_troubleshoot.py

Testing Completed:

Yes, manually verified both call sites (is_agent_version_updated and verify_selinux_state) produce correct results with the tuple-based comparison; script imports cleanly on Python 3.13.
Verified _strtobool handles all truthy/falsy values and raises on invalid input.

Checked that the validations are passing and have addressed any issues that are present:

Python syntax is valid, no KQL or YAML templates are modified.

tchbla added 3 commits July 28, 2026 10:40
…13 compat

distutils was removed in Python 3.13, causing an ImportError on import.
replace with a local _parse_version() helper using tuple comparison.
Replace hardcoded `/usr/local/bin/python3` shebang with the portable `#!/usr/bin/env python3` form.

The hardcoded path assumes a specific Python installation location, which breaks on systems where Python is installed elsewhere (e.g. via pyenv, conda, or OS package managers).

Using `env` resolves `python3` from `$PATH`, correctly handling
virtual environments and cross-platform installations.
@tchbla
tchbla requested review from a team as code owners July 30, 2026 08:24
@v-atulyadav
v-atulyadav requested a review from Copilot July 30, 2026 11:45
@v-atulyadav v-atulyadav added Connector Connector specialty review needed python Pull requests that update Python code labels Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the Syslog AMA troubleshooting script to avoid distutils (removed in Python 3.13+) by replacing StrictVersion comparisons with a local tuple-based version parser and bumping the script version.

Changes:

  • Replace distutils.version.StrictVersion with a local _parse_version() helper.
  • Update version comparisons to use tuple comparison.
  • Update shebang and bump inline SCRIPT_VERSION to 2.52.

Comment thread DataConnectors/Syslog/Sentinel_AMA_troubleshoot.py Outdated
Comment thread DataConnectors/Syslog/Sentinel_AMA_troubleshoot.py Outdated
tchbla added 2 commits July 31, 2026 11:22
Pad to three components so "1.2" == "1.2.0" as StrictVersion did.
Also add two blank lines before the function definition (PEP 8 E302).
Inline equivalent _strtobool helper preserving original behavior including ValueError on  unrecognized values.
@tchbla
tchbla requested a review from a team as a code owner July 31, 2026 09:26
@tchbla

tchbla commented Jul 31, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Connector Connector specialty review needed python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants